package app.page;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.remote.AndroidMobileCapabilityType;
import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.remote.MobilePlatform;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

public class WeWork {

    AppiumDriver<MobileElement> driver;

    public MainPage startWeWork() throws MalformedURLException {
         DesiredCapabilities capabilities = new DesiredCapabilities();
         capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "Android Emulator");
         capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE,"com.tencent.wework");
         capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY,".launch.LaunchSplashActivity");
         capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, MobilePlatform.ANDROID);
         capabilities.setCapability(MobileCapabilityType.NO_RESET, true);
         driver = new AppiumDriver<>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);

         driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
         return new MainPage(driver);

     }


     public void close(){
        driver.close();
     }

}
